/* 
 * @moduleName: TransFormMultiSelectUtil.js
 * @Desc: select多选
 * @Author: djkloop 
 * @Date: 2017-11-30 12:20:43 
 * @Last Modified by: djkloop
 * @Last Modified time: 2017-12-12 02:18:17
 */

 import React from 'react'
 import colUtil from './ColWrapperUtil'
 import { Select } from 'antd';
 const Option = Select.Option;

 export default {
  transformMultiSelect(field,type) {
    let _rules = field.dateRules && type === 'single' ? field.dateRules.rules : [];
    const options = [];
    field.options.forEach((option) => {
      options.push(<Option key={option.key} disabled={option.disabled?true:null} value={option.key}>{option.value}</Option>);
    });
    return colUtil.colWrapper((getFieldDecorator, forUpdate) => getFieldDecorator(field.key, {rules:_rules,initialValue: forUpdate ? undefined : field.defaultValue})(
      <Select mode={field.tage?"tags":"multiple"} placeholder={field.placeholder || '请选择'} size="default">
        {options}
      </Select>
    ), field);
  }
 }
